{{ extend '../pub/template.html'}}

{{ block 'user-name' }}
当前登录用户{{msg}}&nbsp;&nbsp;用户角色：{{role == 'on' ? '管理员':'普通人'}}
{{ /block }}

{{ block 'user-position'}}
<!-- 面包屑导航 -->
<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item"><a href="/admin/user">首页</a></li>
    <li class="breadcrumb-item"><a>用户信息管理</a></li>
    <li class="breadcrumb-item active" aria-current="page">修改用户</li>
  </ol>
</nav>

<!-- 内容主体 -->
<div class="card border-0" style="margin: 16px;padding: 16px;min-height: 400px;">
  <form style="padding: 0px 200px;" method="POST" action="/admin/usermodify">

    <div class="form-group">
      <label for="Username" class="col-form-label-sm">用户名:</label>
      <input type="username" class="form-control form-control-sm" id="Username" name="Username"
        value="{{resulf.Username}}">
    </div>

    <div class="form-group">
      <label for="Password" class="col-form-label-sm">密码:</label>
      <input type="password" class="form-control form-control-sm" id="Password" name="Password"
        value="{{resulf.Password}}">
    </div>

    <div class="form-group">
      <label for="role" class="col-form-label-sm">角色:</label>
      <select class="form-control form-control-sm" id="role" name="role">
        <option value="on">管理员</option>
        <option value="in">普通人</option>
      </select>
      <br>
    </div>

    <div class="form-group">
      <label for="email" class="col-form-label-sm">电子邮箱:</label>
      <input type="email" class="form-control form-control-sm" id="email" name="email" value="{{resulf.Email}}">
    </div>

    <button type="submit" class="btn btn-primary btn-sm" id="submit">提交</button>
    <button type="button" class="btn btn-primary btn-sm" id="subCancel">取消</button>
  </form>
</div>
{{ /block}}

{{ block 'script' }}
<script>
  // 点击取消触发该事件
  $('#subCancel').on('click', function () {
    window.location.href = '/admin/userlist';
  });

  $('form').on('submit', function () {
    if ($('#Username').val().trim().length == 0) {
      alert('请输入用户名')
      return false;
    } else if ($('#Password').val().trim().length == 0) {
      alert('请输入密码')
      return false;
    } else if ($('#role').val().trim().length == 0) {
      alert('请选择身份');
      return false;
    } else if ($('#email').val().trim().length == 0) {
      alert('请输入邮箱');
      return false;
    }
  });
</script>
{{ /block }}